home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Utilities / vim-5.1 / doc / cmdline.txt < prev    next >
Encoding:
Text File  |  1998-04-05  |  23.7 KB  |  585 lines

  1. *cmdline.txt*   For Vim version 5.1.  Last modification: 1998 Mar 25
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Command-line mode                    *mode-cmdline* *:*
  8.  
  9. Command-line mode is used to enter Ex commands (":"), search patterns
  10. ("/" and "?"), and filter commands ("!").
  11.  
  12. 1. Command line editing        |cmdline-editing|
  13. 2. Command line completion    |cmdline-completion|
  14. 3. Ex command lines        |cmdline-lines|
  15. 4. Ex command line ranges    |cmdline-ranges|
  16. 5. Ex special characters    |cmdline-special|
  17.  
  18. ==============================================================================
  19. 1. Command line editing                    *cmdline-editing*
  20.  
  21. Normally characters are inserted in front of the cursor position.  You can
  22. move around in the command line with the left and right cursor keys.  With the
  23. <Insert> key, you can toggle between inserting and overstriking characters.
  24. {Vi: can only alter the last character in the line}
  25.  
  26. Note that if your keyboard does not have working cursor keys or any of the
  27. other special keys, you can use ":cnoremap" to define another key for them.
  28. For example, to define tcsh style editing keys:        *tcsh-style*
  29. >    :cnoremap <C-A> <Home>
  30. >    :cnoremap <C-F> <Right>
  31. >    :cnoremap <C-B> <Left>
  32. >    :cnoremap <Esc>b <S-Left>
  33. >    :cnoremap <Esc>f <S-Right>
  34. (<> notation |<>|; type all this literally)
  35.  
  36.                             *cmdline-history*
  37. The command lines that you enter are remembered in a history table.  You can
  38. recall them with the up and down cursor keys.  There are actually three
  39. history tables:
  40. - one for ':' commands
  41. - one for search strings
  42. - one for expressions
  43. These are completely separate.  Each history can only be accessed when
  44. entering the same type of line.
  45. Use the 'history' option to set the number of lines that are remembered
  46. (default: 20).
  47. Notes:
  48. - When you enter a command line that is excactly the same as an older one, the
  49.   old one is removed (to avoid repeated commands moving older commands out of
  50.   the history).
  51. - Only commands that are typed are remembered.  Ones that completely come from
  52.   mappings are not put in the history
  53. - All searches are put in the search history, including the ones that come
  54.   from commands like "*" and "#".  But for a mapping, only the last search is
  55.   remembered (to avoid that long mappings trash the history).
  56. {Vi: no history}
  57.  
  58. There is an automatic completion of names on the command line; see
  59. |cmdline-completion|.
  60.  
  61.                             *c_CTRL-V*
  62. CTRL-V        Insert next non-digit literally.  Up to three digits form the
  63.         decimal value of a single byte.  The non-digit and the three
  64.         digits are not considered for mapping.  This works the same
  65.         way as in Insert mode (see above, |i_CTRL-V|).
  66.                             *c_CTRL-Q*
  67. CTRL-Q        Same as CTRL-V.
  68.  
  69.                             *c_<Left>*
  70. <Left>        cursor left
  71.                             *c_<Right>*
  72. <Right>        cursor right
  73.                             *c_<S-Left>*
  74. <S-Left> or <C-Left>                    *c_<C-Left>*
  75.         cursor one WORD left
  76.                             *c_<S-Right>*
  77. <S-Right> or <C-Right>                    *c_<C-Right>*
  78.         cursor one WORD right
  79. CTRL-B or <Home>                    *c_CTRL-B* *c_<Home>*
  80.         cursor to beginning of command line
  81. CTRL-E or <End>                        *c_CTRL-E* *c_<End>*
  82.         cursor to end of command line
  83.  
  84.                             *c_<LeftMouse>*
  85. <LeftMouse>    cursor to position of mouse click.
  86.  
  87. CTRL-H                            *c_<BS>* *c_CTRL-H*
  88. <BS>        delete the character in front of the cursor (see |:fixdel| if
  89.         your <BS> key does not do what you want).
  90.                             *c_<Del>*
  91. <Del>        delete the character under the cursor (at end of line:
  92.         character before the cursor) (see |:fixdel| if your <Del>
  93.         key does not do what you want).
  94.                             *c_CTRL-W*
  95. CTRL-W        delete the word before the cursor
  96.                             *c_CTRL-U*
  97. CTRL-U        remove all characters
  98.  
  99.         Note: if the command line becomes empty with one of the
  100.         delete commands, Command-line mode is quit.
  101.                             *c_<Insert>*
  102. <Insert>    Toggle between insert and overstrike.  {not in Vi}
  103.  
  104. {char1} <BS> {char2}    or                *c_digraph*
  105. CTRL-K {char1} {char2}                    *c_CTRL-K*
  106.         enter digraph (see |digraphs|).  When {char1} is a special
  107.         key, the code for that key is inserted.  {not in Vi}
  108.  
  109. CTRL-R <0-9a-z"%#:-=>                    *c_CTRL-R*
  110.         Insert the contents of a numbered or named register.  Between
  111.         typing CTRL-R and the second character '"' will be displayed
  112.         to indicate that you are expected to enter the name of a
  113.         register.  The text is inserted as if you typed it, but
  114.         mappings and abbreviations are not used.  Special registers:
  115.             '"'    the unnamed register, containing the text of
  116.                 the last delete or yank
  117.             '%'    the current file name
  118.             '#'    the alternate file name
  119.             ':'    the last command line
  120.             '-'    the last small (less than a line) delete
  121.             '='    the expression register: you are prompted to
  122.                 enter an expression (see |expression|)
  123.         Note: The '.' register (last inserted text) is not available
  124.         here.  See |registers| about registers.  {not in Vi}
  125.  
  126. CTRL-J                        *c_CTRL-J* *c_<NL>* *c_<CR>*
  127. <CR> or <NL>    start entered command
  128.                             *c_<Esc>*
  129. <Esc>        When typed and 'x' not present in 'cpoptions', quit
  130.         Command-line mode without executing.  In macros or when 'x'
  131.         present in 'cpoptions', start entered command.
  132.                             *c_CTRL-C*
  133. CTRL-C        quit command line without executing
  134.  
  135.                             *c_<Up>*
  136. <Up>        recall older command line from history, whose beginning
  137.         matches the current command line (see below).
  138.                             *c_<Down>*
  139. <Down>        recall more recent command line from history, whose beginning
  140.         matches the current command line (see below).
  141.  
  142.                             *c_<S-Up>* *c_<PageUp>*
  143. <S-Up> or <PageUp>
  144.         recall older command line from history
  145.                         *c_<S-Down>* *c_<PageDown>*
  146. <S-Down> or <PageDown>
  147.         recall more recent command line from history
  148.  
  149. CTRL-D        command line completion (see |cmdline-completion|)
  150. 'wildchar' option
  151.         command line completion (see |cmdline-completion|)
  152. CTRL-N        command line completion (see |cmdline-completion|)
  153. CTRL-P        command line completion (see |cmdline-completion|)
  154. CTRL-A        command line completion (see |cmdline-completion|)
  155. CTRL-L        command line completion (see |cmdline-completion|)
  156.  
  157.                             *c_CTRL-_*
  158. CTRL-_        a - switch between Hebrew and English keyboard mode, which is
  159.         private to the command line and not related to hkmap.
  160.         This is useful when Hebrew text entry is required in the
  161.         command line, searches, abbreviations, etc.  Applies only if
  162.         Vim is compiled with the |+rightleft| feature.
  163.         See |rightleft.txt|.
  164.  
  165.         b - switch between Farsi and English keyboard mode, which is
  166.         private to the command line and not related to fkmap.  In
  167.         Farsi keyboard mode the characters are inserted in revese
  168.         insert manner.  This is useful when Farsi text entry is
  169.         required in the command line, searches, abbreviations, etc.
  170.         Applies only if Vim is compiled with the |+farsi| feature.
  171.         See |farsi.txt|.
  172.  
  173. The <Up> and <Down> keys take the current command line as a search string.
  174. The beginning of the next/previous command lines are compared with this
  175. string.  The first line that matches is the new command line.  When typing
  176. these two keys repeatedly, the same string is used again.  For example, this
  177. can be used to find the previous substitute command: Type ":s" and then <Up>.
  178. The same could be done by typing <S-Up> a number of times until the desired
  179. command line is shown.  (Note: the shifted arrow keys do not work on all
  180. terminals)
  181.  
  182. ==============================================================================
  183. 2. Command line completion                *cmdline-completion*
  184.  
  185. When editing the command line, a few commands can be used to complete the
  186. word before the cursor.  This is available for:
  187.  
  188. - Command names: at the start of the command line.  Works always.
  189. - tags: only after the ":tag" command.
  190. - file names: only after a command that accepts a file name or a setting for
  191.   an option that can be set to a file name.  This is called file name
  192.   completion.
  193. - options: only after the ":set" command.
  194.  
  195. These are the commands that can be used:
  196.  
  197.                             *c_CTRL-D*
  198. CTRL-D        List names that match the pattern in front of the cursor.
  199.         When showing file names, directories are highlighted (see
  200.         'highlight' option)
  201.                     *c_CTRL-I* *c_wildchar* *c_<Tab>*
  202. 'wildchar' option
  203.         A match is done on the pattern in front of the cursor.  The
  204.         match (if there are several, the first match) is inserted
  205.         in place of the pattern.  (Note: does not work inside a
  206.         macro, because <Tab> or <Esc> are mostly used as 'wildchar',
  207.         and these have a special meaning in some macros.) When typed
  208.         again and there were multiple matches, the next
  209.         match is inserted.  After the last match, the first is used
  210.         again (wrap around).
  211.                             *c_CTRL-N*
  212. CTRL-N        After using 'wildchar' which got multiple matches, go to next
  213.         match.  Otherwise recall more recent command line from history.
  214. <S-Tab>                            *c_CTRL-P* *c_<S-Tab>*
  215. CTRL-P        After using 'wildchar' which got multiple matches, go to
  216.         previous match.  Otherwise recall older command line from
  217.         history.  <S-Tab> only works with the GUI, on the Amiga and
  218.         with MS-DOS.
  219.                             *c_CTRL-A*
  220. CTRL-A        All names that match the pattern in front of the cursor are
  221.         inserted.
  222.                             *c_CTRL-L*
  223. CTRL-L        A match is done on the pattern in front of the cursor.  If
  224.         there is one match, it is inserted in place of the pattern.
  225.         If there are multiple matches the longest common part is
  226.         inserted in place of the pattern.
  227.  
  228. The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
  229. a previous version <Esc> was used).  In the pattern standard wildcards '*' and
  230. '?' are accepted.  '*' matches any string, '?' matches exactly one character.
  231.  
  232. If you like tcsh's autolist completion, you can use this mapping:
  233.     :cnoremap X <C-L><C-D>
  234. (Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D)
  235. This will find the longest match and then list all matching files.
  236.  
  237.                             *suffixes*
  238. For file name completion you can use the 'suffixes' option to set a priority
  239. between files with almost the same name.  If there are multiple matches,
  240. those files with an extension that is in the 'suffixes' option are ignored.
  241. The default is ".bak,~,.o,.h,.info,.swp", which means that files ending in
  242. ".bak", "~", ".o", ".h", ".info" and ".swp" are sometimes ignored.  It is
  243. impossible to ignore suffixes with two dots.  Examples:
  244.  
  245.   pattern:    files:                match:    ~
  246.    test*    test.c test.h test.o        test.c
  247.    test*    test.h test.o            test.h and test.o
  248.    test*    test.i test.h test.c        test.i and test.c
  249.  
  250. If there is more than one matching file (after ignoring the ones matching
  251. the 'suffixes' option) the first file name is inserted.  You can see that
  252. there is only one match when you type 'wildchar' twice and the completed
  253. match stays the same.  You can get to the other matches by entering
  254. 'wildchar', CTRL-N or CTRL-P.  All files are included, also the ones with
  255. extensions matching the 'suffixes' option.
  256.  
  257. The old value of an option can be obtained by hitting 'wildchar' just after
  258. the '='.  For example, typing 'wildchar' after ":set dir=" will insert the
  259. current value of 'dir'.  This overrules file name completion for the options
  260. that take a file name.
  261.  
  262. If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
  263. your .cshrc:
  264. >    xmodmap -e "keysym Tab = Tab Find"
  265. And this in your .vimrc:
  266. >    cmap <Esc>[1~ <C-P>        (<C-P> is CTRL-P)
  267.  
  268. ==============================================================================
  269. 3. Ex command lines                    *cmdline-lines*
  270.  
  271. The Ex commands have a few specialties:
  272.  
  273.                             *:quote*
  274. '"' at the start of a line causes the whole line to be ignored.  '"'
  275. after a command causes the rest of the line to be ignored.  This can be used
  276. to add comments.  Example:
  277. >    :set ai        "set 'autoindent' option
  278. It is not possible to add a comment to a shell command ":!cmd" or to the
  279. ":map" command and friends, because they see the '"' as part of their
  280. argument.
  281.  
  282.                             *:bar*
  283. '|' can be used to separate commands, so you can give multiple commands in one
  284. line.  If you want to use '|' as an argument, precede it with '\'.
  285.  
  286. These commands see the '|' as their argument, and can therefore not be
  287. followed by another command:
  288.     :autocmd
  289.     :global
  290.     :normal
  291.     :perl
  292.     :perldo
  293.     :pyfile
  294.     :python
  295.     :read !
  296.     :vglobal
  297.     :write !
  298.     :[range]!
  299.  
  300. Note that this is confusing (inherited from Vi): With ":g" the '|' is included
  301. in the command, with ":s" it is not.
  302.  
  303. To be able to use another command anyway, use the ":execute" command.
  304. Example (append the output of "ls" and jump to the first line):
  305. >    :execute 'r !ls' | '[
  306.  
  307. There is one exception: When the 'b' flag is present in 'cpoptions', with the
  308. ":map" and ":abbr" commands and friends CTRL-V needs to be used instead of
  309. '\'.  You can also use "<Bar>" instead.  See also |map_bar|.
  310.  
  311. Examples:
  312. >    :!ls | wc        view the output of two commands
  313. >    :r !ls | wc        insert the same output in the text
  314. >    :%g/foo/p|>        moves all matching lines one shiftwidth
  315. >    :%s/foo/bar/|>        moves one line one shiftwidth
  316. >    :map q 10^V|        map "q" to "10|"
  317. >    :map q 10\| map \ l    map "q" to "10\" and map "\" to "l"
  318. >                    (when 'b' is present in 'cpoptions')
  319.  
  320. You can also use <NL> to separate commands in the same way as with '|'.  To
  321. insert a <NL> use CTRL-V CTRL-J.  "^@" will be shown.  Using '|' is the
  322. preferred method.  But for external commands a <NL> must be used, because a
  323. '|' is included in the external command.  To avoid the special meaning of <NL>
  324. it must be preceded with a backslash.  Example:
  325. >    :r !date<NL>-join
  326. This reads the current date into the file and joins it with the previous line.
  327.  
  328. Note that when the command before the '|' generates an error, the following
  329. commands will not be executed.
  330.  
  331.  
  332. Because of Vi compatibility the following strange commands are supported:
  333. >    :|            print current line (like ":p")
  334. >    :3|            print line 3 (like ":3p")
  335. >    :3            goto line 3
  336.  
  337. A colon is allowed between the range and the command name.  It is ignored
  338. (this is Vi compatible).  For example:
  339. >    :1,$:s/pat/string
  340.  
  341. When the character '%' or '#' is used where a file name is expected, they are
  342. expanded to the current and alternate file name (see the chapter "editing
  343. files" |:_%| |:_#|).
  344.  
  345. Embedded spaces in file names are allowed on the Amiga if one file name is
  346. expected as argument.  Trailing spaces will be ignored, unless escaped with a
  347. backslash or CTRL-V.  Note that the ":next" command uses spaces to separate
  348. file names.  Escape the spaces to include them in a file name.  Example:
  349. >    :next foo\ bar goes\ to school\
  350. starts editing the three files "foo bar", "goes to" and "school ".
  351.  
  352. When you want to use the special characters '"' or '|' in a command, or want
  353. to use '%' or '#' in a file name, precede them with a backslash.  The
  354. backslash is not required in a range and in the ":substitute" command.
  355.  
  356.                             *:_!*
  357. The '!' (bang) character after an Ex command makes the command behave in a
  358. different way.  The '!' should be placed immediately after the command, without
  359. any blanks in between.  If you insert blanks the '!' will be seen as an
  360. argument for the command, which has a different meaning.  For example:
  361.     :w! name    write the current buffer to file "name", overwriting
  362.             any existing file
  363.     :w !name    send the current buffer as standard input to command
  364.             "name"
  365.  
  366. ==============================================================================
  367. 4. Ex command line ranges            *cmdline-ranges* *[range]*
  368.  
  369. Some Ex commands accept a line range in front of them.  This is noted as
  370. [range].  It consists of one or more line specifiers, separated with ',' or
  371. ';'.
  372.  
  373.                         *:,* *:;*
  374. When separated with ';' the cursor position will be set to that line
  375. before interpreting the next line specifier.  This doesn't happen for ','.
  376. Examples:
  377. >    4,/this line/        from line 4 till match with "this line" after
  378. >                the cursor line.
  379. >    5;/that line/        from line 5 till match with "that line" after
  380. >                line 5.
  381.  
  382. The default line specifier for most commands is the cursor position, but the
  383. commands ":write" and ":global" have the whole file (1,$) as default.
  384.  
  385. If more line specifiers are given than required for the command, the first
  386. one(s) will be ignored.
  387.  
  388. Line numbers may be specified with:            *:range*
  389.     {number}    an absolute line number
  390.     .        the current line              *:.*
  391.     $        the last line in the file          *:$*
  392.     %        equal to 1,$ (the entire file)          *:%*
  393.     *        equal to '<,'> (the Visual area)      *:star*
  394.     't        position of mark t (lower case)          *:'*
  395.     /{pattern}[/]    the next line where {pattern} matches      *:/*
  396.     ?{pattern}[?]    the previous line where {pattern} matches *:?*
  397.     \/        the next line where the previously used search
  398.             pattern matches
  399.     \?        the previous line where the previously used search
  400.             pattern matches
  401.     \&        the next line where the previously used substitute
  402.             pattern matches
  403.  
  404. Each may be followed (several times) by '+' or '-' and an optional number.
  405. This number is added or subtracted from the preceding line number.  If the
  406. number is omitted, 1 is used.
  407.  
  408. The "/" and "?" after {pattern} are required to separate the pattern from
  409. anything that follows.
  410.  
  411. The "/" and "?" may be preceded with another address.  The search starts from
  412. there.  The difference from using ';' is that the cursor isn't moved.
  413. Examples:
  414. >    /pat1//pat2/    Find line containing "pat2" after line containing
  415. >            "pat1", without moving the cursor.
  416. >    7;/pat2/    Find line containing "pat2", after line 7, leaving
  417. >            the cursor in line 7.
  418.  
  419. The {number} must be between 0 and the number of lines in the file.  A 0 is
  420. interpreted as a 1, except with the commands tag, pop and read.
  421.  
  422. Examples:
  423. >    .+3        three lines below the cursor
  424. >    /that/+1    the line below the next line containing "that"
  425. >    .,$        from current line until end of file
  426. >    0;/that        the first line containing "that"
  427.  
  428. Some commands allow for a count after the command.  This count is used as the
  429. number of lines to be used, starting with the line given in the last line
  430. specifier (the default is the cursor line).  The commands that accept a count
  431. are the ones that use a range but do not have a file name argument (because
  432. a file name can also be a number).
  433.  
  434. Examples:
  435. >    :s/x/X/g 5    substitute 'x' by 'X' in the current line and four
  436. >            following lines
  437. >    :23d 4        delete lines 23, 24, 25 and 26
  438.  
  439. A range should have the lower line number first.  If this is not the case, Vim
  440. will ask you if it should swap the line numbers.  This is not done within the
  441. global command ":g".
  442.  
  443.                             *N:*
  444. When giving a count before entering ":", this is translated into:
  445.         :.,.+(count - 1)
  446. In words: The 'count' lines at and after the cursor.  Example: To delete
  447. three lines:
  448. >        3:d<CR>        is translated into: .,.+2d<CR>
  449.  
  450.                             *v_:*
  451. {Visual}:    Starts a command line with the Visual selected lines as a
  452.         range.  The code ":'<,'>" is used for this range, which makes
  453.         it possible to select a similar line from the command line
  454.         history for repeating a command on different Visually selected
  455.         lines.
  456.  
  457. ==============================================================================
  458. 5. Ex special characters                *cmdline-special*
  459.  
  460. In Ex commands, at places where a file name can be used, the following
  461. characters have a special meaning.  These can also be used in the expression
  462. function expand() |expand()|.
  463.     %       is replaced with the current file name        *:_%*
  464.     #       is replaced with the alternate file name        *:_#*
  465.     #n       (where n is a number) is replaced with the file name of
  466.            buffer n.  "#0" is the same as "#"
  467.  
  468. To avoid the special meaning of '%' and '#' insert a backslash before it.
  469. Detail: The special meaning is always escaped when there is a backslash before
  470. it, no matter how many backslashes.
  471.     you type:        result    ~
  472.        #            alternate.file
  473.        \#            #
  474.        \\#            \#
  475.  
  476.                    *:<cword>* *:<cWORD>* *:<cfile>* *<cfile>*
  477.                    *:<sfile>* *<sfile>* *:<afile>* *<afile>*
  478. Note: the next four are typed literally, these are not special keys!
  479.     <cword>    is replaced with the word under the cursor
  480.     <cWORD>    is replaced with the WORD under the cursor (see |WORD|)
  481.     <cfile>    is replaced with the path name under the cursor
  482.     <afile>    when executing autocommands, is replaced with the file name
  483.            for a file read or write
  484.     <sfile>    when executing a ":source" command, is replaced with the
  485.            file name of the sourced file.
  486.  
  487.         *filename-modifiers* *:_%:* *::p* *::h* *::t* *::r* *::e*
  488. After "%", "#", "#n", "<cfile>", "<sfile>" or "<afile>" modifiers can be given
  489. (in this order):
  490.     :p       Make file name a full path.  Must be the first modifier.
  491.     :h       Head of the file name (the last component and any
  492.            separators removed).  Cannot be used with :e, :r or :t.
  493.            Can be repeated to remove several components at the end.
  494.            When the file name is an absolute path (starts with "/" for
  495.            Unix; "x:\" for MS-DOS, WIN32, OS/2; "drive:" for Amiga),
  496.            that part is not removed.  When there is no head (path is
  497.            relative to current directory) the result is empty.
  498.     :t       Tail of the file name (last component of the name).  Must
  499.            precede any :r or :e.
  500.     :r       Root of the file name (the last extension removed).  When
  501.            there is only an extension (file name that starts with
  502.            '.', e.g., ".vimrc"), it is not removed.  Can be repeated to
  503.            remove several extensions (last one first).
  504.     :e       Extension of the file name.  Only makes sense when used
  505.            alone.  When there is no extension the result is empty.
  506.            When there is only an extension (file name that starts with
  507.            '.'), the result is empty.  Can be repeated to include more
  508.            extensions.  If there are not enough extensions (but at
  509.            least one) as much as possible are included.
  510.  
  511. Examples, when the file name is "src/version.c":
  512. >    :p       /home/mool/vim/src/version.c
  513. >    :h              src
  514. >    :p:h       /home/mool/vim/src
  515. >    :p:h:h       /home/mool/vim
  516. >    :t                  version.c
  517. >    :p:t                  version.c
  518. >    :r              src/version
  519. >    :p:r       /home/mool/vim/src/version
  520. >    :t:r                  version
  521. >    :e                      c
  522.  
  523. Examples, when the file name is "src/version.c.gz":
  524. >    :p       /home/mool/vim/src/version.c.gz
  525. >    :e                                gz
  526. >    :e:e                                  c.gz
  527. >    :e:e:e                                c.gz
  528. >    :e:e:r                                c
  529. >    :r                        src/version.c
  530. >    :r:e                                  c
  531. >    :r:r                      src/version
  532. >    :r:r:r                    src/version
  533.  
  534.                     *extension-removal* *:_%<*
  535. If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
  536. name is removed (everything after and including the last '.' in the file
  537. name).  This is included for backwards compatibility with version 3.0, the
  538. ":r" form is preferred.  Examples:
  539.  
  540. >    %        current file name
  541. >    %<        current file name without extension
  542. >    #        alternate file name for current window
  543. >    #<        idem, without extension
  544. >    #31        alternate file number 31
  545. >    #31<        idem, without extension
  546. >    <cword>        word under the cursor
  547. >    <cWORD>        WORD under the cursor (see |WORD|)
  548. >    <cfile>        path name under the cursor
  549. >    <cfile><    idem, without extension
  550.  
  551. Note: Where a file name is expected wildcards expansion is done.  On Unix the
  552. shell is used for this.  Backticks also work, like in
  553.     :n `echo *.c`
  554. But expansion is only done if there are any wildcards before expanding the
  555. '%', '#', etc..  This avoids expanding wildcards inside a file name.  If you
  556. want to expand the result of <cfile>, add a wildcard character to it.
  557. Examples: (alternate file name is "?readme?")
  558.     command        expands to  ~
  559.     :e #        :e ?readme?
  560.     :e `ls #`    :e {files matching "?readme?"}
  561.     :e #.*        :e {files matching "?readme?.*"}
  562.     :cd <cfile>    :cd {file name under cursor}
  563.     :cd <cfile>*    :cd {file name under cursor plus "*" and then expanded}
  564.  
  565.                             *filename-backslash*
  566. For filesystems that use a backslash as directory separator (MS-DOS, Windows,
  567. OS/2), it's a bit difficult to recognize a backslash that is used to escape
  568. the special meaning of the next character.  The general rule is: If the
  569. backslash is followed by a normal file name character, it does not have a
  570. special meaning.  Therefore "\file\foo" is a valid file name, you don't have
  571. to type the backslash twice.
  572.  
  573. And exception is the '$' sign.  It is a valid character in a file name.  But
  574. to avoid a file name like "$home" to be interpreted as an environment variable,
  575. it needs to be preceded by a backslash.  Therefore you need to use "/\$home"
  576. for the file "$home" in the root directory.  A few examples:
  577.  
  578.     FILE NAME    INTERPRETED AS    ~
  579.     $home        expanded to value of environment var $home
  580.     \$home        file "$home" in current directory
  581.     /\$home        file "$home" in root directory
  582.     \\$home        file "\\", followed by expanded $home
  583.  
  584.  vim:tw=78:ts=8:sw=8:
  585.